package com.yljk.servicemanager.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.yilijk.base.basedialog.BaseDialog;
import com.yilijk.base.basedialog.DialogChain;
import com.yilijk.base.utils.ALog;
import com.yljk.servicemanager.R;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2022/01/04
 */
public class WisdomDialog extends BaseDialog implements View.OnClickListener{

    public WisdomDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_layout_wisdom);
        findViewById(R.id.wisdom_img).setOnClickListener(this);
        findViewById(R.id.wisdom_close).setOnClickListener(this);
        this.setCanceledOnTouchOutside(false);
        setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (chain()!=null){
                    chain().process();
                    ALog.i(getContext(),"智慧医声活动弹窗消失");
                }
            }
        });
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.wisdom_img) {
            dismiss();
        } else if (id == R.id.wisdom_close) {
            dismiss();
        }
    }

    @Override
    public void intercept(@NonNull DialogChain chain) {
        super.intercept(chain);
        //dialog弹出的条件

        if (true){
            this.show();
        }else{
            if (chain!=null){
                chain.process();
            }
        }
    }

    @Override
    public void show() {
        super.show();
    }
}
